package org.lq.rbac.vo.util;

import org.lq.rbac.dto.MenuDTO;
import org.lq.rbac.vo.MenuVO;

import java.util.LinkedList;
import java.util.List;

public class Populate {
    public static void dto2vo(MenuDTO menuDTO, MenuVO menuVO){
        menuVO.setId(menuDTO.getId());
        menuVO.setLabel(menuDTO.getName());
        menuVO.setDisabled(menuDTO.isDisabled());
        menuVO.setIsLeaf(menuDTO.isParent());
        menuVO.setUrl(menuDTO.getUrl());
        if (menuDTO.getChildren()!=null){
            List<MenuVO> children=new LinkedList<>();
            for (MenuDTO childMenuDTO:menuDTO.getChildren()){
                MenuVO childMenuVO=new MenuVO();
                dto2vo(childMenuDTO,childMenuVO);
                children.add(childMenuVO);
            }
            menuVO.setChildern(children);
        }

    }


}
